home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / packages / powertcp.exe / TALK.FR_ / TALK.bin (.txt)
Encoding:
Visual Basic Form  |  1995-02-16  |  9.2 KB  |  257 lines

  1. VERSION 2.00
  2. Begin Form frmTalk 
  3.    BackColor       =   &H8000000F&
  4.    Caption         =   "Talk"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   2148
  7.    ClientTop       =   1620
  8.    ClientWidth     =   7368
  9.    Height          =   6468
  10.    Icon            =   TALK.FRX:0000
  11.    Left            =   2100
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5820
  14.    ScaleWidth      =   7368
  15.    Top             =   1020
  16.    Width           =   7464
  17.    Begin PowerTCP_TCP TCPlisten 
  18.       Flags           =   0
  19.       Left            =   1620
  20.       LocalDotAddr    =   ""
  21.       OemLicense      =   ""
  22.       RemoteHost      =   ""
  23.       RemotePort      =   7
  24.       Top             =   900
  25.    End
  26.    Begin PowerTCP_TCP TCPconnect 
  27.       Flags           =   0
  28.       Left            =   360
  29.       LocalDotAddr    =   ""
  30.       OemLicense      =   ""
  31.       RemoteHost      =   ""
  32.       RemotePort      =   7
  33.       Top             =   900
  34.    End
  35.    Begin TextBox txtRecv 
  36.       Height          =   495
  37.       Left            =   1200
  38.       MultiLine       =   -1  'True
  39.       ScrollBars      =   2  'Vertical
  40.       TabIndex        =   1
  41.       Top             =   0
  42.       Width           =   1215
  43.    End
  44.    Begin TextBox txtSend 
  45.       Height          =   495
  46.       Left            =   0
  47.       MultiLine       =   -1  'True
  48.       ScrollBars      =   2  'Vertical
  49.       TabIndex        =   0
  50.       Top             =   0
  51.       Width           =   1215
  52.    End
  53.    Begin Menu mnuConversation 
  54.       Caption         =   "&Conversation"
  55.       Begin Menu mnuCListen 
  56.          Caption         =   "&Listen..."
  57.       End
  58.       Begin Menu mnuCStopListening 
  59.          Caption         =   "&Stop Listening"
  60.          Enabled         =   0   'False
  61.       End
  62.       Begin Menu mnuCSep1 
  63.          Caption         =   "-"
  64.       End
  65.       Begin Menu mnuCConnect 
  66.          Caption         =   "&Connect..."
  67.       End
  68.       Begin Menu mnuCDisconnect 
  69.          Caption         =   "&Disconnect"
  70.          Enabled         =   0   'False
  71.       End
  72.       Begin Menu mnuCSep2 
  73.          Caption         =   "-"
  74.       End
  75.       Begin Menu mnuCExit 
  76.          Caption         =   "E&xit"
  77.       End
  78.    End
  79.    Begin Menu mnuHelp 
  80.       Caption         =   "&Help"
  81.       Begin Menu mnuHHowToUse 
  82.          Caption         =   "&How to Use Talk"
  83.       End
  84.       Begin Menu mnuHSep 
  85.          Caption         =   "-"
  86.       End
  87.       Begin Menu mnuHelpAboutTalk 
  88.          Caption         =   "&About Talk..."
  89.       End
  90.    End
  91. ' This sample application is copyright 1994 by Dart
  92. ' Communications. All rights reserved.
  93. ' You may use this application and any Visual Basic code
  94. ' within it for your own uses, and may modify it for your
  95. ' own needs.
  96. ' IMPORTANT: We MUST use the API MessageBox function
  97. ' instead of the VB MsgBox function. See the PowerTCP
  98. ' README for more information.
  99. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  100. Declare Sub ShellAbout Lib "SHELL.DLL" (ByVal hWnd As Integer, ByVal AppName As String, ByVal AppInfo As String, ByVal hIcon As Integer)
  101. Const BorderWidth% = 30
  102. ' Show parameters
  103. Const MODAL = 1
  104. Const MODELESS = 0
  105. ' MsgBox parameters
  106. Const MB_OK = 0                 ' OK button only
  107. Sub Form_Resize ()
  108.     On Error Resume Next    ' In case we get some kind
  109.                             ' of weird number because
  110.                             ' the form gets too small
  111.     txtSend.Left = BorderWidth
  112.     txtSend.Top = BorderWidth
  113.     txtRecv.Top = BorderWidth
  114.     txtSend.Height = ScaleHeight - 2 * BorderWidth
  115.     txtRecv.Height = txtSend.Height
  116.     txtSend.Width = (ScaleWidth - 3 * BorderWidth) / 2
  117.     txtRecv.Width = txtSend.Width
  118.     txtRecv.Left = txtSend.Width + 2 * BorderWidth
  119. End Sub
  120. Sub Form_Unload (Cancel As Integer)
  121.     End
  122. End Sub
  123. Sub mnuCConnect_Click ()
  124.     frmConnect.Show MODAL
  125.     If frmConnect.Tag = True Then
  126.         tcpConnect.RemoteHost = frmConnect.txtHostName
  127.         tcpConnect.RemotePort = Val(frmConnect.txtPort)
  128.         tcpConnect.Action = CONNECT
  129.     End If
  130.     frmConnect.Tag = ""
  131. End Sub
  132. Sub mnuCDisconnect_Click ()
  133.     tcpConnect.Action = CLOSECOMM
  134. End Sub
  135. Sub mnuCExit_Click ()
  136.     tcpListen.Action = ABORTCOMM
  137.     tcpConnect.Action = ABORTCOMM
  138.     End
  139. End Sub
  140. Sub mnuCListen_Click ()
  141.     ' Hide the host name from the connect dialog
  142.     frmConnect.Label1.Visible = False
  143.     frmConnect.txtHostName.Visible = False
  144.     frmConnect.Show MODAL
  145.     If frmConnect.Tag = True Then
  146.         tcpListen.LocalPort = Val(frmConnect.txtPort)
  147.         tcpListen.Action = LISTEN
  148.     End If
  149.     frmConnect.Label1.Visible = True
  150.     frmConnect.txtHostName.Visible = True
  151.     frmConnect.Tag = ""
  152. End Sub
  153. Sub mnuCStopListening_Click ()
  154.     tcpListen.Action = CLOSECOMM
  155. End Sub
  156. Sub mnuHelpAboutTalk_Click ()
  157.     ShellAbout Me.hWnd, "PowerTCP Talk Sample Application", "Talk Version 1.0 
  158.  1994 Dart Communications" & Chr$(10) & "(315) 841-8106", Me.Icon
  159. End Sub
  160. Sub mnuHHowToUse_Click ()
  161.     Msg$ = "To use Talk, first begin the Talk application"
  162.     Msg$ = Msg$ + " on one computer. Then click on Listen..."
  163.     Msg$ = Msg$ + " from the File menu, so that Talk"
  164.     Msg$ = Msg$ + " is listening on a certain port. Next,"
  165.     Msg$ = Msg$ + " begin Talk on another computer."
  166.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 1/3", 0)
  167.     Msg$ = "Choose Connect... from the File menu,"
  168.     Msg$ = Msg$ + " and fill in the computer name of the"
  169.     Msg$ = Msg$ + " first computer and the port it was"
  170.     Msg$ = Msg$ + " listening on."
  171.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 2/3", 0)
  172.     Msg$ = " Now both computers can communicate"
  173.     Msg$ = Msg$ + " by typing in the left text box."
  174.     Msg$ = Msg$ + " Whatever appears in the left text box"
  175.     Msg$ = Msg$ + " will also appear in the right text"
  176.     Msg$ = Msg$ + " box on the other computer." & Chr$(10)
  177.     Msg$ = Msg$ + Chr$(10) & "Choose Disconnect from"
  178.     Msg$ = Msg$ + " the File menu on either computer to"
  179.     Msg$ = Msg$ + " end the connection."
  180.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 3/3", 0)
  181. End Sub
  182. Sub tcpConnect_Connect ()
  183.     mnuCConnect.Enabled = False
  184.     mnuCDisconnect.Enabled = True
  185. End Sub
  186. Sub tcpConnect_Exception (ErrorCode As Integer, ErrorDesc As String)
  187.     If ErrorCode = PT_CLOSED Or ErrorCode = PT_ABORTED Then
  188.         suc% = MessageBox(Me.hWnd, "Connection to host lost", "Talk", MB_OK)
  189.         mnuCConnect.Enabled = True
  190.         mnuCDisconnect.Enabled = False
  191.     Else
  192.         suc% = MessageBox(Me.hWnd, ErrorDesc & "(" & Format$(ErrorCode) & ").", "Talk", MB_OK)
  193.         ' Destroy the connection
  194.         tcpConnect.Action = CLOSECOMM
  195.     End If
  196. End Sub
  197. Sub tcpConnect_Recv (RecvData As String)
  198.     ' We have to check if any of the characters received
  199.     ' are carriage returns or backspaces, and process
  200.     ' them accordingly
  201.     For i = 1 To Len(RecvData)
  202.         Select Case Mid$(RecvData, i, 1)
  203.         Case Chr$(13)           ' Carriage return
  204.             ' Even though only a Chr$(13) is sent, under
  205.             ' Windows a return is Chr$(13)+Chr$(10).
  206.             txtRecv = txtRecv & Chr$(13) & Chr$(10)
  207.         Case Chr$(8)            ' Backspace
  208.             txtRecv = Left$(txtRecv, Len(txtRecv) - 1)
  209.         Case Else               ' Normal
  210.             txtRecv = txtRecv + Mid$(RecvData, i, 1)
  211.         End Select
  212.     Next i
  213. End Sub
  214. Sub tcpListen_Accept (NewSession As Long)
  215.     ' Only create a new session if no session currently
  216.     ' exists
  217.     If tcpConnect.State = CLOSED Then
  218.         tcpConnect.Session = NewSession
  219.     Else
  220.         suc% = MessageBox(Me.hWnd, "Talk could not accept a new connection from a remote computer; only one at a time is allowed." & Chr$(10) & Chr$(10) & "If you are trying to connect to yourself, you must use two copies of Talk, and have one connect to the other.", "Connection Refused", 0)
  221.     End If
  222. End Sub
  223. Sub tcpListen_Exception (ErrorCode As Integer, ErrorDesc As String)
  224.     If ErrorCode = PT_CLOSED Or ErrorCode = PT_ABORTED Then
  225.         suc% = MessageBox(Me.hWnd, "Listening stopped", "Talk", MB_OK)
  226.         mnuCListen.Enabled = True
  227.         mnuCStopListening.Enabled = False
  228.     Else
  229.         suc% = MessageBox(Me.hWnd, ErrorDesc & "(" & Format$(ErrorCode) & ").", "Talk", MB_OK)
  230.         
  231.         ' Stop listening
  232.         tcpListen.Action = CLOSECOMM
  233.     End If
  234. End Sub
  235. Sub tcpListen_Listen ()
  236.     mnuCListen.Enabled = False
  237.     mnuCStopListening.Enabled = True
  238. End Sub
  239. Sub txtRecv_KeyPress (KeyAscii As Integer)
  240.     Msg$ = "To send text, type in the left box. The right"
  241.     Msg$ = Msg$ + " box is where all received text is"
  242.     Msg$ = Msg$ + " displayed."
  243.     suc% = MessageBox(Me.hWnd, Msg$, "Talk", 0)
  244.     ' Prevent the character from appearing
  245.     KeyAscii = 0
  246. End Sub
  247. Sub txtSend_KeyPress (KeyAscii As Integer)
  248.     If tcpConnect.State = CONNECTED Then
  249.         ' Make sure the character appears at the end
  250.         txtSend.SelStart = Len(txtSend)
  251.         tcpConnect.Send = Chr$(KeyAscii)
  252.     Else
  253.         ' Prevent the character from appearing
  254.         KeyAscii = 0
  255.     End If
  256. End Sub
  257.